#ifndef RSA_H
#define RSA_H

#include <iostream>
#include <string>
#include <vector>
#include <stdexcept>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/rand.h>

class Rsa
{
public:
    Rsa();
    ~Rsa();
    bool generateRSAKey(RSA*& rsa, int keySize = 2048);
    bool saveRSAKey(const RSA* rsa, const std::string& filename, bool isPrivate);
    RSA* loadRSAKey(const std::string& filename, bool isPrivate);
    std::vector<unsigned char> rsaEncrypt(const RSA* rsa, const std::vector<unsigned char>& data);
    std::vector<unsigned char> rsaDecrypt(const RSA* rsa, const std::vector<unsigned char>& encryptedData);
    void printOpenSSLError();
};


#endif // RSA_H
